<!DOCTYPE html>
<html>
<head>
    <% include ../include/css_header.html %>
    <title>活动：<%=act.name %></title>
    <style>
        .input-group{
            margin-bottom: 10px;
        }
        .hide_more{
            display: none;
        }
    </style>
</head>
<body class="actlist_bg">
    <div class="container">
        <div class="top_bar">
            <a class="icon-arrow-left bar_left" href="/faction/<%=act.belongFaction?act.belongFaction._id:'' %>"></a>
            <% if(act.creator.id === me.id && !act.hasExpired){ %>
            <a class="icon-compose bar_right" href="/actEdit/<%=act._id %>"></a>
            <% } %>
        </div>
        <div style="text-align: center;color: #ffffff;" class="font_shadow_133000">
            <div style="height: 20px;"></div>
            <div>
                <h4><strong><%=act.name %></strong></h4>
            </div>
            <% if(!act.hasExpired){ %>
                <% if(act.creator.id === me.id){ %>
            <div style="margin:20px 0 0 0">
                <button type="button" class="btn btn-info toShare"
                        style="height: 100px;width: 100px;border-radius: 50px;border: 5px solid rgba(255, 255, 255, 0.3);">
                    <h2 style="margin: 0px;"><strong>邀请</strong></h2>
                </button>
            </div>
                <% }else if(hasJoined){ %>
            <div style="margin:20px 0 0 0">
                <button type="button" class="btn btn-warning" id="deseShow" data-loading-text="来啦!"
                        style="height: 100px;width: 100px;border-radius: 50px;border: 5px solid rgba(255, 255, 255, 0.3);">
                    <h2 style="margin: 0px;"><strong>得瑟</strong></h2>
                </button>
            </div>
                <% }else{ %>
            <div style="margin:20px 0 0 0">
                <button type="button" class="btn btn-success" id="toJoin" data-loading-text="来啦!"
                        style="height: 100px;width: 100px;border-radius: 50px;border: 5px solid rgba(255, 255, 255, 0.3);">
                    <h2 style="margin: 0px;"><strong>签到</strong></h2>
                </button>
            </div>
                <% } %>
            <% }else{ %>
            <div style="margin:20px 0 0 0">
                <button type="button" class="btn btn-default"
                        style="height: 100px;width: 100px;border-radius: 50px; color: #ffffff;background-color: #e0e0e0;">
                    <h2 style="margin: 0px;"><strong>结束</strong></h2>
                </button>
            </div>
            <% } %>
            <div style="margin-top:20px">
                <% if(act.attendNum == 0){ %><h6>你是第一个，抢沙发！</h6><% }else{ %><h6>已有<%=act.attendNum %>位英雄</h6><% } %>
            </div>
        </div>
        <div class="row" style="position: relative;margin: 0;">
            <div class="col-xs-12 bg_op_panel" style="min-height: 400px;">
            <div class="invite_info" style="position: relative;top: 10px;">
                <div style="margin-bottom: 10px;">
                    <img src="/img/<%=act.creator.id %>" alt="头像" class="img-rounded">
                    <label>发起人：</label>
                    <strong style="color: #428bca"><%=act.creator.name %></strong>
                </div>
                <div>
                    <label>时间：</label>
                    <strong style="color: #428bca"><%=startTime %></strong>
                    <strong style="color: #000000">(周<%=day %>)</strong>
                </div>
                <div>
                    <label>地点：</label>
                    <%=act.location %>
                </div>
                <div>
                    <label>说明：</label>
                    <p><%=act.remark %></p>
                </div>
                <%
                var attendSize = act.attends.length;
                if(attendSize > 0){
                    var index = 0;
                %>
                <div style="margin-top:20px;"><label>签到人：</label></div>
                <div class="bg_white_panel" id="attendlist">
                    <ul>
                        <%  var attends = act.attends;
                            for(var i=0; i< attendSize; i++){
                                var attend = attends[i];
                                index++;
                        %>
                        <li class="<%=index>6?'hide_more':'' %>">
                            <img src="/img/<%=attend.id %>" alt="10" class="img-rounded size_32">
                            <a href="/user/<%=attend.id %>"><%=attend.name %></a>
                            <%-attendSize>1?'<hr>':''%>
                        </li>
                        <% } %>
                        <% if(attendSize > 6){ %>
                        <li>
                            <div id="loadMore">
                                看看还有谁
                                <span class="icon-arrow-down"></span>
                            </div>
                        </li>
                        <% } %>
                    </ul>
                </div>
                <% }else{ %>
                <div class="bg_white_panel" id="attendlist" style="display: none">
                    <ul></ul>
                </div>
                <% } %>
            </div>
            </div>
        </div>
        <input type="hidden" id="factionId" value="<%=act.belongFaction?act.belongFaction._id:'' %>"/>
        <img id="msg_logo" src="http://wechatjh.fourjoy.net/flogo/<%=act.belongFaction?act.belongFaction._id:'' %>.jpg" onError="this.src='http://wechatjh.fourjoy.net/message_img.jpg';" style="display: none;"/>
        <% include ../include/show_gift.html %>
        <% include ../include/guide_tip.html %>
        <% include ../include/join_faction.html %>
        <% include ../include/copyright.html %>
    </div>
    <% include ../include/slide_menu.html %>
    <% include ../include/js_footer.html %>
    <script src="<%=_locals.static_js_path %>/faction_invite.js"></script>
    <script type="text/javascript">
        var actId = '<%=act._id %>';
        var userId = '<%=me.id %>';
        var factionId = '<%=act.belongFaction._id%>';
        var score = '<%=score|| 0 %>';
        var no = '<%=no || 0%>';
        var from = '<%=from %>';
        var shareData = {
            img_url: $('#msg_logo').attr('src'),
            link: siteGlobal.SITE_HOST+'/invite/'+actId+'/'+userId,
            title: '快来加入我的聚会:<%=act.name %>，给你惊喜给你好看！',
            desc:'发起人：<%=act.creator.name %>\n时间：<%=startTime %>\n内容：<%=act.remark.substr(0,10) %>...'
        }
        $(function(){
            WeixinUtil.initConfig(['onMenuShareTimeline', 'onMenuShareAppMessage'], true, function(){
                WeixinUtil.sharePage(shareData.title, shareData.desc, shareData.img_url, shareData.link)
            })
        })
    </script>
</body>
</html>